package cn.exrick.xboot.modules.content.controller;

import cn.exrick.xboot.base.XbootBaseController;
import cn.exrick.xboot.common.utils.PageUtil;
import cn.exrick.xboot.common.utils.ResultUtil;
import cn.exrick.xboot.common.vo.PageVo;
import cn.exrick.xboot.common.vo.Result;
import cn.exrick.xboot.common.vo.SearchVo;
import cn.exrick.xboot.modules.content.entity.HontLog;
import cn.exrick.xboot.modules.content.service.HontLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author Exrick
 */
@Slf4j
@RestController
@Api(description = "前台日志管理接口")
@RequestMapping("/xboot/hontLog")
@Transactional
public class HontLogController{

    @Autowired
    private HontLogService hontLogService;

    @RequestMapping(value = "/getByCondition", method = RequestMethod.GET)
    @ApiOperation(value = "多条件分页获取")
    public Result<Page<HontLog>> getByCondition(HontLog hontLog,
                                                SearchVo searchVo,
                                                PageVo pageVo){

        pageVo.setSort("createTime");
        pageVo.setOrder("desc");
        Page<HontLog> page = hontLogService.findByCondition(hontLog, searchVo, PageUtil.initPage(pageVo));
        return new ResultUtil<Page<HontLog>>().setData(page);
    }
}
